home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 3
/
Amoszine 3.adf
/
MORE_SOURCE
/
F1Multi_Numbers.AMOS
/
F1Multi_Numbers.amosSourceCode
Wrap
AMOS Source Code
|
1992-02-26
|
3KB
|
96 lines
'
' Routine for Random Selection of Different Numbers ( By Dave King )
'
' This routine can be used to pick each number from a given total once
' e.g. If your enter 10 as your number a string called PICK$ is created
' containing each number from 1 to 10. Here's how it works ........
' To handle any number from 1 - 999 PICK$ is created with preceding 0's
' in our example of 10 PICK$ will = "001002003004005006007008009010"
' The Random Select routine picks a random number dependant on the
' Length of PICK$ Divided by 3, then to ensure this number is not
' chosen again it is removed from PICK$
'
' Open a Hires Screen
'
Screen Open 0,640,250,16,Hires : Curs Off : Flash Off
BEGIN:
'
' Set Paper colour to Black and clear screen, then hide the mouse
'
Paper 0 : Cls : Hide On
'
' Request a number
'
Locate 3,7 : Print "Enter a Number Between 2 and 638"
Locate 3,10 : Input NUM$
Cls
'
' Set Variable NUMENTRIES to equal The Number entered
'
NUMENTRIES=Val(NUM$)
'
' Set random number seed
'
Randomize Timer
'
' Set GAP Variable - only used for spacing the text
'
GAP=(Len(NUM$)*8)+5
'
' Now create PICK$ - obviously the larger the number entered the longer
' it takes to create the string - with 638 the string is 1,914 Characters
' in length ( 638 Multiplied by 3 )
'
CREATE_PICK_STRING:
PICK$=""
For X=1 To NUMENTRIES
XX$=Mid$(Str$(X),2)
'
' Place preceding 0's if required
'
If Len(XX$)=1 Then XX$="00"+XX$
If Len(XX$)=2 Then XX$="0"+XX$
PICK$=PICK$+XX$
Next X
'
' Randomly Select from PICK$
'
RANDOM_SELECT_FROM_PICK_STRING:
'
' Set XP and YP Variables - only used for positioning text
'
XP=1 : YP=8
Ink 2,0
For X=1 To NUMENTRIES
XX=Rnd((Len(PICK$)/3)) : XX=XX-1
If XX=-1 Then XX=0
XX=(XX*3)+1
'
' The Variable SEL$ is returned with a different Number Each Pass
'
SEL$=Mid$(PICK$,XX,3)
'
' Now remove unwanted 0's from SEL$
'
If Left$(SEL$,2)="00" Then SEL$=Right$(SEL$,1)
If Left$(SEL$,1)="0" Then SEL$=Right$(SEL$,2)
'
' Display the randomly selected number
'
Text XP,YP,SEL$
'
' Set SP to equal the Start Position of selected number within PICK$
' Set EP to equal SP+2 - End Position of selected number within PICK$
'
SP=XX : EP=XX+2 : YP=YP+8
'
' Reduce PICK$
'
PICK$=Mid$(PICK$,1,SP-1)+Mid$(PICK$,EP+1,Len(PICK$))
If YP>232
XP=XP+GAP : YP=8
End If
Next X
Ink 2,6 : Text 30,241," Bet you can't find a Duplicated Number ? - Press any Key to re-start. "
Wait Key
Goto BEGIN